$(document).ready(function () {
    sbxx.onload();
})
var sbxx = (function () {
	var init = function () {
    	layui.use('form', function(){
			  var form = layui.form
		});
    }
    return {
        onload : function () {
        	init();
            sbxx.tableDataSbf();
            sbxx.tableDataSb();
            sbxx.dateShow();
            sbxx.formTab();
        },
       /*表格数据交互*/
      tableDataSbf: function() {//社保费信息表格
 		var data = [{
 				"number": "1",
 				"sbDate": "2018-01-01",
 				"dateStart":"2018-02-01",
 				"dateFinish":"2018-02-28",
 				"sbMoney":"150.11",
 				"pzxh":"410199001745",
 				"operation":null
 			},
 			{
 				"number": "2",
 				"sbDate": "2018-01-01",
 				"dateStart":"2018-02-01",
 				"dateFinish":"2018-02-28",
 				"sbMoney":"150.11",
 				"pzxh":"410199001745",
 				"operation":null
 			},
 			{
 				"number": "3",
 				"sbDate": "2018-01-01",
 				"dateStart":"2018-02-01",
 				"dateFinish":"2018-02-28",
 				"sbMoney":"150.11",
 				"pzxh":"410199001745",
 				"operation":null
 			},
 			{
 				"number": "4",
 				"sbDate": "2018-01-01",
 				"dateStart":"2018-02-01",
 				"dateFinish":"2018-02-28",
 				"sbMoney":"150.11",
 				"pzxh":"410199001745",
 				"operation":null
 			}
 		];
 		$('#wepSbfcx').DataTable({
 			"data": data,
 			"columnDefs": [
 				{
 					"targets": -1,
 					"data": null,
 					"render": function(data, type, full, meta) {
 						return '<a href="#"><span class="btn wxl_bg_lan1">查看明细</span></a>'
 					}
 				}
 			],
 			"columns": [
 			    {
 					"data": "number"
 				},
 				{
 					"data": "sbDate"
 				},
 				{
 					"data": "dateStart"
 				},
 				{
 					"data": "dateFinish"
 				},
 				{
 					"data": "sbMoney"
 				},
 				{
 					"data": "pzxh"
 				},
 				{
 					"data": "operation"
 				}
 			],
// 			"paging": false,
 			"info": false,
 			"ordering": false,
 			"lengthChange": false,
 			"searching": false
 		});
     },
     tableDataSb: function() {//社保申报表格
 		var data = [{
 				"number": "1",
 				"zsxm": "个人所得税",
 				"zspm":"其他利息、股息、红利所得",
 				"sbDate":"2018-01-01",
 				"dateStart":"2018-02-01",
 				"dateFinish":"2018-02-28",
 				"jfDate":"2018-01-01",
 				"jfje":"150.11"
 			},
 			{
 				"number": "2",
 				"zsxm": "个人所得税",
 				"zspm":"其他利息、股息、红利所得",
 				"sbDate":"2018-01-01",
 				"dateStart":"2018-02-01",
 				"dateFinish":"2018-02-28",
 				"jfDate":"2018-01-01",
 				"jfje":"150.11"
 			},
 			{
 				"number": "3",
 				"zsxm": "个人所得税",
 				"zspm":"其他利息、股息、红利所得",
 				"sbDate":"2018-01-01",
 				"dateStart":"2018-02-01",
 				"dateFinish":"2018-02-28",
 				"jfDate":"2018-01-01",
 				"jfje":"150.11"
 			},
 			{
 				"number": "4",
 				"zsxm": "个人所得税",
 				"zspm":"其他利息、股息、红利所得",
 				"sbDate":"2018-01-01",
 				"dateStart":"2018-02-01",
 				"dateFinish":"2018-02-28",
 				"jfDate":"2018-01-01",
 				"jfje":"150.11"
 			}
 		];
 		$('#wepSbxx').DataTable({
 			"data": data,
 			"columns": [
 			    {
 					"data": "number"
 				},
 				{
 					"data": "zsxm"
 				},
 				{
 					"data": "zspm"
 				},
 				{
 					"data": "sbDate"
 				},
 				{
 					"data": "dateStart"
 				},
 				{
 					"data": "dateFinish"
 				},
 				{
 					"data": "jfDate"
 				},
 				{
 					"data": "jfje"
 				}
 			],
// 			"paging": false,
 			"info": false,
 			"ordering": false,
 			"lengthChange": false,
 			"searching": false
 		});
     },
     /*日期显示*/
        dateShow:function(){
        	layui.use('laydate', function(){
				var laydate = layui.laydate;
				function dateObj(dom1,dom2){//结束时间不小于开始时间
					var startDate   = laydate.render({
						elem: dom1,
						done:function(value,date){
							if( value !== '' ){
								endDate.config.min.year = date.year;
								endDate.config.min.month = date.month - 1;
								endDate.config.min.date = date.date;
							}else{
								endDate.config.min.year = '';
								endDate.config.min.month = '';
								endDate.config.min.date = '';
							}
						}
					});
					var endDate  = laydate.render({
						elem: dom2,
						done:function(value,date){
							if( value !== '' ){
								startDate.config.max.year = date.year;
								startDate.config.max.month = date.month - 1;
								startDate.config.max.date = date.date;
							}else{
								startDate.config.max.year = '';
								startDate.config.max.month = '';
								startDate.config.max.date = '';
							}
						}
					});
				}
				dateObj('#wep_date1','#wep_date2');
				dateObj('#wep_date3','#wep_date4');
				dateObj('#wep_date5','#wep_date6');
				dateObj('#wep_date7','#wep_date8');
			})
        },
        /*tab选项卡*/
       formTab:function(){
	       	$(".wep_table_tab span").click(function(){
	       		$(this).addClass("active").siblings("span").removeClass("active");
				var n=$(this).index();
				$(".wep_xxcx_box").eq(n).show().siblings(".wep_xxcx_box").hide();
				
			})
	    }
    }
})();